# -*- coding: utf-8 -*-
'''
Created on Apr 3, 2013

@author: LONG HOANG GIANG
'''

import gzip as _gzip
import os
import json
from AESCipher import AESCipher


def encrypt(path):
    
    fp = _gzip.open(path, 'rb')
    data = fp.read()
    print data
    fp.close()
    if (json.loads(data)):
        cipher = AESCipher()
        encrypted = cipher.encrypt(data)
        print encrypted
        fp = _gzip.open(path, 'wb')
        fp.write(encrypted)
        fp.close()



if __name__ == '__main__':
    
    encrypt("/longhoanggiang/truyentext/{0}/data".format("truyencotich"))
    print '> Finished'
    
    os._exit(1)